/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dsmsforkjoin;

import java.util.*;
import tuplegenerator.Tuple;
/**
 *
 *
 */
public class ListQueue<T extends Tuple> implements IForkQueue<T> {
    
    protected ArrayList<T> list = new ArrayList<T>();

    
    @Override
    public void addItem(T st) {
        list.add(st);
    }
    
    @Override
	public void sort() {
        Collections.sort(list);
    }
    
    @Override
    public T removeHead() {
        if (list.size() <= 0) return null;
        T t = list.get(0);
        list.remove(0);
        return t;
    }
    
    @Override
    public T getItem(int index) {
        return this.list.get(index);
    }

	@Override
	public void setSize(int size) {
		// do nothing
	}

	@Override
	public int getSize() {
		return this.list.size();
	}

	@Override
	public boolean isEmpty() {
		return (this.list.size() <= 0);
	}
	
}
